//
//  SwiftUIView_State.swift
//  SwiftUIPractice
//
//  Created by 都三点半了啊 (external - Project) on 2024/9/12.
//

import SwiftUI

struct SwiftUIView_State: View {
    
    @State var backgroundColro = Color.gray

    @State var title = "默认标题"

    @State var count = 1
    
    var body: some View {
        
        ZStack {
            
            backgroundColro.ignoresSafeArea()
            
            VStack (spacing: 20) {
                
                Text("这是我的标题").font(.title)
                
                Text("这个是计数器: \(count)").font(.headline).underline()
                
                HStack(spacing: 50) {
                    
                    Button(action: {
                        count += 1
                        
                        title = "1#"
                        backgroundColro = .brown
                    }, label: {
                        Text("第一个按钮")
                    })
                    
                    
                    Button(action: {
                        count -= 1
                        title = "2#"
                        backgroundColro = .purple
                    }, label: {
                        Text("第二个按钮")
                    })
                    
                }
                
            }
        }
        .foregroundStyle(.white)
        
        
    }
}

#Preview {
    SwiftUIView_State()
}
